package com.hzy.seataaccount.account.controller;

import com.hzy.account.entities.Account;
import com.hzy.common.entities.CommonResult;
import com.hzy.seataaccount.account.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * 这里填写描述
 * 填写修改说明
 *
 * @author hzy
 * @version Revision:v1.0
 * @since Date:2022-03-15 16:35
 */
@Slf4j
@RestController
public class AccountController {

    @Resource
    private AccountService accountService;

    @PostMapping("/account/decrease")
    public CommonResult<Account> decrease(@RequestParam("userId") String userId, @RequestParam("money") BigDecimal money){
        Account account = accountService.decrease(userId, money);
        return new CommonResult<Account>(200, "账户扣减成功!", account);
    }

}
